# -*- coding: utf-8 -*-
# @Time    : 2021/4/13 20:07
# @Author  : mokez
# @Email   : 1569089678@qq.com
# @File    : walden.py
# @Software: PyCharm

# 词频统计
# • 已经有一个瓦尔登湖的文本，
# “Walden.txt”
# • 统计这篇文章的词频（每个词出现的次数）
# • 不统计标点符号
# • The和the被统计成同一个词（不区分大小写）
# • 输出格式：{ 'the': 10, 'is': 45....}
import string

# with open("Walden.txt", mode="r", encoding="utf-8") as fp:
#     txt_line = fp.read().translate(str.maketrans("", "", string.punctuation)).lower().split()
#     dc = {}
#     for word in txt_line:
#         if word in dc:
#             dc[word] += 1
#         else:
#             dc[word] = 1
#     result = sorted(dc.items(), key=lambda x: x[1], reverse=True)
#     # print(result)
#     for i in result:
#         print(f"'{i[0]}':{i[1]}")

str1="hello, world! sanchuang tongle"
print(str1.translate(str.maketrans("", "" ,string.punctuation)))